package com.ayuan.blog.common.wechat.message;

import com.ayuan.blog.common.wechat.common.WeChatBaseUtil;
import com.ayuan.blog.common.wechat.common.WeChatResponse;
import com.ayuan.blog.common.wechat.message.bean.WeChatMessage;
import lombok.extern.log4j.Log4j2;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xiaozhu on 16/5/22.
 */
@Log4j2
public class WeChatMessageClient {

    private final static String MESSAGE_CUSTOM_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s";

    public static void messageCustomSend(String token, String text, String openId) {
        WeChatMessage weChatMessage = new WeChatMessage();
        weChatMessage.setToUser(openId);
        weChatMessage.setMsgType("text");
        Map<String, String> textMap = new HashMap<String, String>();
        textMap.put("content", text);
        weChatMessage.setText(textMap);
        WeChatBaseUtil.sendWeChatHTTPRequest(token, weChatMessage, MESSAGE_CUSTOM_SEND_URL, WeChatResponse.class);
    }
}
